//
//  YLChangePasswordViewController.m
//  YLFinanceService
//
//  Created by she1323 on 2017/11/10.
//  Copyright © 2017年 she1323. All rights reserved.
//

#import "YLChangePasswordViewController.h"
#import "YLChangePasswordViewModel.h"
@interface YLChangePasswordViewController ()
@property (weak, nonatomic) IBOutlet UITextField *passwordOriginalTextField;
@property (weak, nonatomic) IBOutlet UITextField *passwordNewTextField;
@property (weak, nonatomic) IBOutlet UITextField *passwordSureTextField;
@property (weak, nonatomic) IBOutlet UIButton *sureButton;
@property (nonatomic, strong) YLChangePasswordViewModel *viewModel;
@end

@implementation YLChangePasswordViewController

- (YLChangePasswordViewModel *)viewModel
{
    if (!_viewModel) {
        _viewModel = [[YLChangePasswordViewModel alloc] init];
    }
    return _viewModel;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"更换登录密码";
    [self bindViewModel];
    
   
    
}
- (void)bindViewModel
{
    RAC(self.sureButton, enabled) = self.viewModel.passwordChangeEnableSiganl;
    RAC(self.viewModel, passwordNew) = _passwordNewTextField.rac_textSignal;
    RAC(self.viewModel, passwordSure) = _passwordSureTextField.rac_textSignal;
    RAC(self.viewModel, passwordOriginal) = _passwordOriginalTextField.rac_textSignal;
}

- (IBAction)seePassword:(UIButton *)sender {
    sender.selected = !sender.selected;
    _passwordSureTextField.secureTextEntry = !sender.selected;
   
}
- (IBAction)sure:(UIButton *)sender {
    __weak typeof(self) weakSelf = self;
    [[self.viewModel.requestCommand execute:nil] subscribeNext:^(id  _Nullable x) {
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
